<?php
require_once BACKGROUND_COMMON_ACTION_SERVICE_DIR . '/default.php';

class background_order_confirm_return_action_service extends background_default_common_action_service
{
    protected static $_instance;

    public static function get_instance()
    {
        if (null === self::$_instance) {
            self::$_instance = new self();
        }

        return self::$_instance;
    }


    protected function _current_page_process()
    {
        //var_dump(__METHOD__); exit();
                
        $result = array('status' => 0, 'message' => '', 'data' => array());
    
        $request_data = $_GET;
        $id = init_user_data_key($request_data, 'id', 'int');
         
        if(empty($id)){
            $result['status']  = -400;
            $result['message'] = '请选择订单';
        }else{   
            $model_background_order = wwy_resource_container::get_model_background_order();
            //var_dump($model_background_order); exit();
            $old_order_info = $model_background_order->find($id);
            //var_dump($old_order_info); exit();
            if(empty($old_order_info)){
                $result['status']  = -400;
                $result['message'] = '该订单不存在';
            }else{        
                $update_time = time();
                $order_info = array();
                $order_info['id']          = $id;
                $order_info['status']      = -2;
                $order_info['confirm_return_time'] = $update_time;
                $order_info['update_time'] = $update_time;
            
                //$row_count = $model_background_order->update_order_status($order_info);
                $row_count = $model_background_order->set_confirm_return($order_info);
                //var_dump($row_count); exit();
                 
                if($row_count === false){
                    $result['status']  = -400;
                    $result['message'] = '操作失败';
                }else{
                    $result['status']  = 1;
                    $result['message'] = '操作成功';
                }
                //var_dump($result); exit();
            }
        }
	    
	    self::set_view_status($result['status']);
	    self::set_view_message($result['message']);
    }
}